﻿using System.Collections.Generic;
using encrpt;

namespace wkwxml
{
    public class Connection
    {
        public string Host
        {
            get { return ConnectionInfo["Host"]; }
            set { ConnectionInfo["Host"] = value; }
        }

        public string Port
        {
            get { return ConnectionInfo["Port"]; }
            set { ConnectionInfo["Port"] = value; }
        }

        public string Uid
        {
            get { return ConnectionInfo["Uid"]; }
            set { ConnectionInfo["Uid"] = value; }
        }

        public string Password
        {
            get { return ConnectionInfo["Password"]; }
            set { ConnectionInfo["Password"] = value; }
        }

        public string DataBase
        {
            get { return ConnectionInfo["DataBase"]; }
            set { ConnectionInfo["DataBase"] = value; }
        }

        public string Security
        {
            get { return ConnectionInfo["Persist Security Info"]; }
            private set { ConnectionInfo["Persist Security Info"] = value;}
        }


        public Dictionary<string, string> ConnectionInfo { get; set; }

        public Connection()
        {
            ConnectionInfo = new Dictionary<string, string>(6)
                                 {
                                     {"Host", ""},
                                     {"Port", ""},
                                     {"Uid", ""},
                                     {"Security", "True"},
                                     {"DataBase", ""},
                                     {"Password", ""},
                                     
                                 };
        }

        public Connection(string host, string port, string uid, string password, string database):this()
        {
            RSA.LoadKey();
            Host = RSA.Encrypt(host);
            Port = RSA.Encrypt(port);
            Uid = RSA.Encrypt(uid);
            Password = RSA.Encrypt(password);
            DataBase = RSA.Encrypt(database);
            Security = "True";
        }
    }
}
